import sys

from common.process_handle import process_handle
from exchange.handle.backup.backup_ability import BackupAbility
from exchange.handle.job.job_ability import JobAbility
from exchange.handle.resource.resource_ability import ResourceAbility
from exchange.handle.restore.restore_ability import RestoreAbility
from exchange.logger import log

fun = {
    'CheckApplication': ResourceAbility.check_application,
    'ListApplicationResourceV2': ResourceAbility.list_application_v2,

    'QueryBackupCopy': BackupAbility.query_backup_copy,
    'Backup': BackupAbility.backup,

    'QueryJobPermission': JobAbility.query_job_permission,
    'AbortJob': JobAbility.abort_job,
    'PauseJob': JobAbility.pause_job
}
# exchange Plugin API 入口
if __name__ == '__main__':
    """
    功能描述:执行exchange插件主程序
    参数:
    @1: 请求类型
    @2: 请求的ID
    @3: 主任务ID
    @4: 子任务ID
    输入:
    标准输入数据为外部程序通过管道向插件程序注入的各项参数数据（可能携带敏感数据）
    样例:
    python3 exchange_api.py Backup 1657539915784 2e0c6c0b faa3e2c0
    """
    # 打印日志
    log.info('Enter exchange Plugin process')
    process_handle(log, sys.argv, sys.stdin, fun)
    log.info('Exit  exchange Plugin process')
